Repository navigation
feat(governance): add opt-in hierarchical grants, budgets and attribution - #71
Conversation
…tion TENANT_GOVERNANCE_ENABLED (off by default) applies organisation and team policies to requests in a verified workspace. Model and tool grants intersect with the key's own grants and never widen them. Budgets at every configured level, plus the key's own limits, are reserved together in one atomic operation and settled together; an over-limit level denies the request before dispatch, and an unknown cost keeps its hold at every level. Roles come from a static permission table. Administrators edit policies through /admin/organisations/<org_id>[/teams/<team_id>]/governance with If-Match and audit rows, and /v1/usage gains a workspace breakdown for callers in a workspace. Requests outside a workspace are unchanged (migration 0034).
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
multillm-proxy | de9a471 | Oct 09 2026, 07:59 AM |
Summary
Adds opt-in hierarchical governance for requests in a verified workspace: organisation and team grants intersect with the key's own grants, budgets at every level are reserved together, and usage is attributed to the workspace. With
TENANT_GOVERNANCE_ENABLEDunset oroff(the default), key controls, grants, budgets, reservations, auto-route eligibility andGET /v1/usageare byte-for-byte unchanged, and the new routes return 404. Requests outside a workspace are unchanged even with the flag on.TENANT_GOVERNANCE_ENABLED. Empty means off; a malformed value is off with one warning that leaves the value out.key_controls.model_allowed/provider_allowedandintelligence_policy.eligible.adminedits grants and budgets and reads all workspace usage,billingreads usage and budgets, andmemberreads its own usage. No role can raise another's.BudgetService.check_and_reservereserves every configured level plus the key's own limits in one atomic operation.tenant_budget_exceededwith the level, before dispatch. An unpriced request returns 503unpriced_reservation.tg_identities and do not touch the existing reservation store.GET/PUT /admin/organisations/<org_id>/governanceand.../teams/<team_id>/governance. These need an administrator session, CSRF, the matching role andIf-Match(428 when missing, 412 when stale), and write audit rows.GET /v1/usageadds aworkspacebreakdown for callers in a workspace: their own usage for members, and organisation and team totals foradmin/billing. Estimates stay labelled as estimates.Details are in
docs/tenant-governance.md.Wiring
services/key_controls.py,services/budget_service.py,services/intelligence_policy.pyandroutes/usage.pyget small call sites intoservices/tenant_governance.py. Each returns the existing result while the flag is off or the request has no workspace.worker/tenant-governance-d1.mjs) and native Worker generations.Shared registrations
tests/test_tenant_governance_worker.mjsintest:worker.worker/tenant-governance-d1.mjsin the edge module inventory, and both governance routes in the Flask route inventory.TENANT_GOVERNANCE_ENABLEDin the Container env keys.tenant_governance_policies,tenant_governance_reservations,tenant_governance_components,tenant_governance_baselinesandtenant_governance_auditinREQUIRED_D1_TABLES.Stacked on #70
Migration numbers must be contiguous in each PR, so this branch merges
feat/tenant-hierarchy(#70, migration 0033). Merge that first. SAML federation stacks on this one.Tests
tests/test_tenant_governance.pyandtests/test_tenant_governance_worker.mjscover:npm run test:worker: 1,809 passed.npm run test:integration: 7 passed.cf:migrations:checkreports 34 contiguous, additive migrations.test:deploy, free routes, client headers and thewrangler deploy --dry-runbundle all pass.tests/test_frontend_build.mjsfails locally because@tailwindcss/cliis not installed. It fails the same way on main.Apply the migration before enabling the flag:
npx wrangler d1 migrations apply multillm-intelligence --remote.CI notes
python/nodejobs: the dependency-audit steps fail on every branch, including main. fix(deps): clear the CI dependency audit advisories #42 fixes that.AdmissionCoordinatorDurable Object migration, whichwrangler versions uploadcannot apply. This is expected untilwrangler deployruns on main.This is part of Wave 7. The README line comes with the Wave 7 integration PR.